package L1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * 谁先倒
 */
public class _019 {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] temp = reader.readLine().split(" ");
        int[] Jiu = new int[2];
        Jiu[0]=Integer.valueOf(temp[0]);
        Jiu[1]=Integer.valueOf(temp[1]);
        int A = 0;
        int B = 0;

        int N  = Integer.valueOf(reader.readLine());
        for (int i=0;i<N;i++){
            String[] s = reader.readLine().split(" ");
            int s0 = Integer.valueOf(s[0]);
            int s1 = Integer.valueOf(s[1]);
            int s2 = Integer.valueOf(s[2]);
            int s3 = Integer.valueOf(s[3]);
            if ((s0+s2==s1)&&(s0+s2==s3)){
                continue;
            }else if (s0+s2==s1) {
                Jiu[0]--;
                A++;
            }else if (s0+s2==s3){
                B++;
                Jiu[1]--;
            }

            if (Jiu[0]<0){
                System.out.println("A");
                System.out.println(B);
                break;
            }
            if (Jiu[1]<0){
                System.out.println("B");
                System.out.println(A);
                break;
            }
        }
    }
}
